package org.yatr.yatrc;
import org.antlr.runtime.Token;

public class Log {

	static int errorCount=0;
	static final boolean infolog=false;
	static final boolean infowarn=false;
	static final boolean infoerror=true;

	static int errorCount() {
		return errorCount;
	}
	
	static void logError(Token t, String fmt, Object... msg) {
		errorCount++;
		
		if(!infoerror) return;
		if(null != t){
			System.out.printf("Error near \"%s\" [%d:%d] -> ", t.getText(), t.getLine(), t.getCharPositionInLine());
		} else {
			System.out.printf("Error -> ");
		}
		System.out.printf(fmt, msg);
		System.out.println();
	}
	static void logWarning(Token t, String fmt, Object... msg) {
		if(!infowarn) return;
		if(null != t){
			System.out.printf("Warning near \"%s\" [%d:%d] -> ", t.getText(), t.getLine(), t.getCharPositionInLine());
		} else {
			System.out.printf("Warning -> ");
		}
		System.out.printf(fmt, msg);
		System.out.println();
	}
	static void logInfo(Token t, String fmt, Object... msg) {
		if(!infolog) return;
		if(null != t){
			System.out.printf("Info near \"%s\" [%d:%d] -> ", t.getText(), t.getLine(), t.getCharPositionInLine());
		} else {
			System.out.printf("Info -> ");
		}
		System.out.printf(fmt, msg);
		System.out.println();
	}
}
